# while True:
#     try:
#         a = input()
#         stack = []
#         last_char = ""
#         for i in a:
#             if not stack:
#                 stack.append(i)
#             else:
#                 if i == last_char:
#                     continue
#                 elif i == stack[-1]:
#                     last_char = stack.pop()
#                 else:
#                     stack.append(i)
#
#         print("".join(stack))
#     except:
#         break

str_input = input()
res = list(str_input)
if str_input.isalpha():
    i=1
    while True:
        if i>= len(res):
            break
        elif i >0 and res[i] == res[i-1]:
            res.pop(i)
            res.pop(i-1)
            i-=2
        i += 1
    print(len(res))
else:
    print(0)
